"use strict";
var Premium = Premium || {};

Premium.creative = {
    init: function() {
        Premium.product.initOrientationMessage();
        /* START OF CUSTOM JS */

        switch (document.body.id) {

            case "body_main":
                // main panel code here
                break;

            case "body_bottom":
                // bottom panel code here
                var panelPosition = "top"
                Premium.product.scopeWindow.addEventListener('scroll', function() {
                    if (Premium.jpxApi.getFixedElemPosition() !== panelPosition) {
                        panelPosition = Premium.jpxApi.getFixedElemPosition();
                        Premium.utils.debug(panelPosition);
                        if (panelPosition === "top") {
                            // 'top' instance 
                            gsap.set(".content-top", { visibility: "visible" });
                            gsap.set(".content-bottom", { visibility: "hidden" });
                        } else {
                            // 'bottom' instance
                            gsap.set(".content-top", { visibility: "hidden" });
                            gsap.set(".content-bottom", { visibility: "visible" });
                        }
                    }
                });

                Premium.creative.createVideoPlayerAppended = function(video, container) {
                    Premium.video.pauseWhenOutOfView(true, undefined, undefined, "bottom");
                    /* comment this line if the video is not in view on load 
                    video.play().catch((e)=>{})
                    */
                }

                break;
        }

        /* END OF CUSTOM JS */
    }
};